//
//  AboutUsViewController.m
//  HaierGMS_APP
//
//  Created by 堂堂 on 16/11/11.
//  Copyright © 2016年 堂堂. All rights reserved.
//

#import "AboutUsViewController.h"
#import "UIColor+Hex.h"
#define ScreenHeight [[UIScreen mainScreen] bounds].size.height//获取屏幕高度，兼容性测试
#define ScreenWidth [[UIScreen mainScreen] bounds].size.width//获取屏幕宽度，兼容性测试
@interface AboutUsViewController ()

@end

@implementation AboutUsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    _contentView.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
    [self initView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)initView{
    NSArray *titles = @[@"企业新闻",@"品牌合作",@"服务加盟",@"关于我们"];
    NSArray *content = @[@"Enterprise news",@"Brand",@"Service",@"About us"];
    
    NSArray *images = @[@"about_ours_1",@"about_ours_2",@"about_ours_3",@"about_ours_4"];
    int height = 0;
    for (int i = 0; i < titles.count; i++) {
        UIControl *control = [[UIControl alloc]initWithFrame:CGRectMake(0, height, ScreenWidth, ScreenWidth  / 3)];
        control.backgroundColor = [UIColor whiteColor];
        [control addTarget:self action:@selector(showWebView) forControlEvents:UIControlEventTouchUpInside];
        [_contentView addSubview:control];
        
        UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenWidth / 3)];
        image.image = [UIImage imageNamed:images[i]];
        [control addSubview:image];
        int content_height = ScreenWidth / 5;
        
        CGSize size = [titles[i] sizeWithFont:[UIFont systemFontOfSize:16]];
        UILabel *lab1 = [[UILabel alloc]initWithFrame:CGRectMake(0, content_height - size.height - 5, ScreenWidth, size.height)];
        lab1.textColor = [UIColor whiteColor];
        lab1.text = titles[i];
        lab1.textAlignment = NSTextAlignmentCenter;
        [control addSubview:lab1];
        
        
        UILabel *lab2 = [[UILabel alloc]initWithFrame:CGRectMake(0, content_height, ScreenWidth, size.height + 5)];
        lab2.text = content[i];
        lab2.textColor = [UIColor whiteColor];
        lab2.textAlignment = NSTextAlignmentCenter;
        [control addSubview:lab2];
        
        height = height + ScreenWidth / 3;
        
        
    }
    
    _contentView.contentSize = CGSizeMake(ScreenWidth, height);
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)back_click:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)showWebView{
    
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.gooday365.com"]];  
}
@end
